package myProject.nim;

public class Machine1 extends Rule{
    private String name;
    Machine1(){
        this.name = getInputName("1号机器");
    }
    public String getName(){
        return name;
    }
    public int getXorSum(int[] storeArray,int length){
        int xor = 0;
        for(int i = 0;i < length;i++){
            xor ^= storeArray[i];
        }
        return xor;
    }
    public int getOptimalIdx(int[] storeArray,int length,int x){
        if(x == 0) return 1;
        int idx = -1;
        for(int i = 0;i<length ;i++){
            if(storeArray[i]>(storeArray[i]^x)){
                idx= i;
                break;
            }
        }
        return idx+1;
    }
    public int getOptimalNum(int[] storeArray,int idx,int x){
        if(x == 0)return 1;
        return (storeArray[idx-1] - (storeArray[idx-1]^x));
    }
}
